#include "widget.h"
#include "ui_widget.h"
#include "QRect"
#include "cstdlib"
#include "ctime"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    srand(time(nullptr));
    cnt = 0;
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pbt_y_clicked()
{
    ui->label->setText("谢谢老板！");
    ui->pbt_n->hide();
    ui->pbt_y->hide();
}

void Widget::on_pbt_n_clicked()
{
    int w = rand() % this->geometry().width();
    int h = rand() % this->geometry().height();
    ui->pbt_n->move(w,h);
    ++cnt;
    if(cnt == 1) ui->label->setText("老板，再考虑考虑吧!");
    else if(cnt == 3) ui->label->setText("老板，我真的干不下去了!");
    else if(cnt == 5) ui->label->setText("老板，不要这么绝情!");
    else if(cnt == 7) ui->label->setText("有点过分了，老板!");
    else if(cnt == 9) ui->label->setText("别点了，没用的!");
    else if(cnt == 10)
    {
        ui->label->setText("老板，这是你逼我的!");
        ui->pbt_n->hide();
    }
}

//pressed信号在点击时触发 不需要松开
void Widget::on_pbt_n_pressed()
{
    on_pbt_n_clicked();
}
